import { defineStore } from "pinia"
import { loginResponse } from "@/page/firstPage/api"
type storeType = {
    userInfo: loginResponse
}
export const userStore = defineStore("userStore", {
    //state
    state: (): storeType => ({
        userInfo: localStorage.getItem("userInfo")
            ? JSON.parse(localStorage.getItem("userInfo") as string)
            : { gender: 1, id: 0, tag: "", username: "",img:'' } //本地缓存有userInfo时使用本地 否则使用空数据
    }),
    //getter
    getters: {},
    actions: {
        //注意不要使用箭头函数，会有this指向问题
        // increment(){
        //     this.num+=1
        // }
    }
})
